package com.party.mobile.web.controller.log;

import com.party.core.model.log.LogEvent;
import com.party.core.model.log.LogType;
import com.party.core.service.log.ILogEventService;
import com.party.mobile.web.dto.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 日志控制器
 * Created by wei.li.
 *
 * @date 2018/2/1 0001
 * @time 16:25
 */

@Controller
@RequestMapping(value = "log/event")
public class LogEventController {

    @Autowired
    private ILogEventService logEventService;

    /**
     * 日志写入
     *
     * @param info 日志信息
     * @return 交互数据
     */
    @ResponseBody
    @RequestMapping(value = "writeLog")
    public AjaxResult writeLog(String info){
        /*AjaxResult ajaxResult = new AjaxResult(true);
        LogEvent logEvent = new LogEvent();
        logEvent.setLevelString("INFO");
        logEvent.setLoggerName(LogType.BEHAVIOR_LOG.name());
        logEvent.setFormattedMessage(info);
        logEvent.setEventId(System.currentTimeMillis());
        logEvent.setCallerFilename(this.getClass().getName());
        logEvent.setCallerClass(this.getClass().getTypeName());
        logEvent.setCallerMethod(Thread.currentThread().getStackTrace()[1].getMethodName() );
        logEvent.setCallerLine(String.valueOf(Thread.currentThread().getStackTrace()[1].getLineNumber()));
        logEvent.setBehaviorType(LogType.SYSTEM_LOG.getValue());
        logEventService.insert(logEvent);
        return ajaxResult;*/
        return AjaxResult.success();
    }
}
